#ifndef __LCD_H
#define __LCD_H
#include "stm32h7xx_hal.h"
#include "stm32h7xx_ll_spi.h"
//---------------SPI接口定义
#define LCD_SPI SPI4
#define LCD_SPI_DMA 0
#if LCD_SPI_DMA==1
    #include "stm32h7xx_ll_dma.h"
#endif
//---------------TFT屏芯片定义
#define ILI9486
//---------------配置LCD端口定义----------------
//使用硬件spi;CS、RS、RST配置相应IO口
#define LCD_CS_GPIO GPIOB
#define LCD_CS_GPIO_PIN GPIO_PIN_14
#define LCD_RS_GPIO GPIOB
#define LCD_RS_GPIO_PIN GPIO_PIN_12
#define LCD_RST_GPIO GPIOB
#define LCD_RST_GPIO_PIN GPIO_PIN_13
//相关函数宏定义
#define	LCD_CS_SET(n)  HAL_GPIO_WritePin(LCD_CS_GPIO,LCD_CS_GPIO_PIN,n)
#define	LCD_RS_SET(n)	HAL_GPIO_WritePin(LCD_RS_GPIO,LCD_RS_GPIO_PIN,n)
#define	LCD_RST_SET(n)	HAL_GPIO_WritePin(LCD_RST_GPIO,LCD_RST_GPIO_PIN,n)
#define LCD_DELAY(X) for(int i=0;i<X*5000;i++)
//---------------end LCD端口定义--------------
//---------------用户配置区-------------------
#define USE_HORIZONTAL  	 0//定义液晶屏顺时针旋转方向 	0-0度旋转，1-90度旋转，2-180度旋转，3-270度旋转
//定义LCD的尺寸
#define LCD_W 320
#define LCD_H 480
//--------------end 用户配置-----------------
//LCD重要参数集
typedef struct
{
	uint16_t	width;			//LCD 宽度
	uint16_t	height;			//LCD 高度
	uint16_t	id;				//LCD ID
	uint8_t		dir;			//横屏还是竖屏控制：0，竖屏；1，横屏。
	uint16_t	wramcmd;		//开始写gram指令
	uint16_t	setxcmd;		//设置x坐标指令
	uint16_t	setycmd;		//设置y坐标指令
}_lcd_dev;
extern _lcd_dev lcddev;	//管理LCD重要参数
void LCD_Init(void);
void LCD_Clear(uint16_t Color);
void LCD_SetCursor(uint16_t Xpos, uint16_t Ypos);
void LCD_DrawPoint(uint16_t x,uint16_t y,uint16_t Color);//画点
void LCD_SetWindows(uint16_t XS, uint16_t YS,uint16_t XE,uint16_t YE);
void LCD_Direction(uint8_t Direction );
void LVGL_LCD_Fill(uint16_t XS, uint16_t YS,uint16_t XE, uint16_t YE,uint16_t* Color);
void LVGL_LCD_DMA_Fill(uint16_t XS, uint16_t YS, uint16_t XE, uint16_t YE, uint16_t *Color);
#endif
